package pwd.allen.aop.advice;

import org.springframework.aop.MethodBeforeAdvice;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * 前置通知
 * 可以修改传递给方法的参数，或者通过抛出异常来阻止方法的执行
 *
 * @author 门那粒沙
 * @create 2020-08-30 10:19
 **/
public class MyBeforeAdvice implements MethodBeforeAdvice {

    /**
     * 测试前置通知
     * @param method
     * @param args
     * @param target
     * @throws Throwable
     */
    @Override
    public void before(Method method, Object[] args, Object target) throws Throwable {
        System.out.println(String.format("【MethodBeforeAdvice】Before '%s',args = %s", method.getName(), Arrays.toString(args)));
    }
}
